#include "DBStringContainer.h"
#include "DBConfig.h"
#include "DataBase.h"

// ----------------------------------- StringContainer ----------------------------------------

namespace db
{
    
ERecordType StringContainer::GetType() const
{ 
    return RTP_STRING; 
}

void StringContainer::Load(ReadStream& file)
{
    FileHelper::read_wstring(file, m_data);
}

void StringContainer::Save(WriteStream& file) const
{
    FileHelper::write_wstring(file, m_data);
}

StringContainer::StringContainer()
{
    //
}

StringContainer::StringContainer(const std::wstring& data) :
    m_data(data)
{
    //
}

std::wstring StringContainer::GetAsString() const
{
    return m_data;
}

bool StringContainer::GetAsBool() const
{
    return m_data == V_TRUE;
}
    
u32 StringContainer::GetAsInt() const
{
    return _wtoi(m_data.c_str());
}
    
f32 StringContainer::GetAsFloat() const
{
    return (float)_wtof(m_data.c_str());
}

f64 StringContainer::GetAsDouble() const
{
    return (double)_wtof(m_data.c_str());
}

u32 StringContainer::GetDataSize() const
{
	return m_data.size() * sizeof(wchar_t);
}

const void* StringContainer::GetAsData() const 
{
	return m_data.c_str();
}
    
void StringContainer::Set(const std::wstring& data)
{
    m_data = data;
}

};